package com.sdp.right.task;

import java.time.LocalDate;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.sdp.right.cron.ScheduledOfTask;
import com.sdp.right.db.sys_cron_log.service.ISysCronLogService;
import com.sdp.right.entity.SysCronLog;

@Component
public class CleanSysCronLogTask implements ScheduledOfTask{
	
	@Autowired
	private ISysCronLogService iSysCronLogService;

	@Transactional
	@Override
	public void execute() {
		//定时任务日志，最多保留120天
		LambdaQueryWrapper<SysCronLog> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.le(SysCronLog::getBeginTime, LocalDate.now().plusDays(-120));
		iSysCronLogService.remove(queryWrapper);
	}

}
